package com.example.mobile2021606159yhf0420;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class SchoolAdapter extends RecyclerView.Adapter<SchoolAdapter.ViewHolder> {


    String[] schoolnames;

    public SchoolAdapter(String[] schoolnames) {
        this.schoolnames = schoolnames;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_app, null);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvmainschoolname.setText(schoolnames[position]);
    }

    @Override
    public int getItemCount() {
        return schoolnames.length;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvmainschoolname;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvmainschoolname = itemView.findViewById(R.id.tv_main_schoolname);
        }
    }
}
